from mediator import mediator
from mediator . tests . test_assistant import make_mediator_test_keyword_args

class logic_fake :
    def __init__ ( self ) :
        self . _copy_menu_return = False
        self . _creation_menu_base_created = False
        self . _creation_menu_return = False
        self . _edit_menu_continue = False
        self . _edit_menu_return_to_main_menu = False
        self . _edit_menu_save = False
        self . _edit_menu_save_as = False
        self . _editor_menu_button = False
        self . _main_menu_copy = False
        self . _main_menu_created = False
        self . _main_menu_open = False
        self . _main_menu_rename = False
        self . _open_menu_base_opened = False
        self . _open_menu_return = False
        self . _rename_menu_return = False
        self . _save_as_menu_base_saved = None
        self . _save_as_menu_return = False
        self . _welcome_finished = False
    def on_copy_menu_return ( self ) :
        self . _copy_menu_return = True
    def on_creation_menu_base_created ( self ) :
        self . _creation_menu_base_created = True
    def on_creation_menu_return ( self ) :
        self . _creation_menu_return = True
    def on_edit_menu_continue ( self ) :
        self . _edit_menu_continue = True
    def on_edit_menu_return_to_main_menu ( self ) :
        self . _edit_menu_return_to_main_menu = True
    def on_edit_menu_save ( self ) :
        self . _edit_menu_save = True
    def on_edit_menu_save_as ( self ) :
        self . _edit_menu_save_as = True
    def on_editor_menu_button ( self ) :
        self . _editor_menu_button = True
    def on_main_menu_copy ( self ) :
        self . _main_menu_copy = True
    def on_main_menu_create ( self ) :
        self . _main_menu_created = True
    def on_main_menu_open ( self ) :
        self . _main_menu_open = True
    def on_main_menu_quit ( self ) :
        self . _main_menu_quited = True
    def on_main_menu_rename ( self ) :
        self . _main_menu_rename = True 
    def on_open_menu_base_opened ( self ) :
        self . _open_menu_base_opened = True
    def on_open_menu_return ( self ) :
        self . _open_menu_return = True
    def on_rename_menu_return ( self ) :
        self . _rename_menu_return = True
    def on_save_as_menu_base_saved ( self , base_name ) :
        self . _save_as_menu_base_saved = base_name
    def on_save_as_menu_return ( self ) :
        self . _save_as_menu_return = True
    def on_welcome_finished ( self ) :
        self . _welcome_finished = True
    def start ( self ) :
        mediator_logic_tests . _call_history += [ logic_fake . start ]

class arbitrary_module_fake :
    def start ( self ) :
        mediator_logic_tests . _call_history += [ arbitrary_module_fake . start ]

class mediator_logic_tests : 
    'mediator_logic'
    def __init__ ( self , test ) :
        mediator_logic_tests . _call_history = [ ]
        self . _test = test
        self . _logic = logic_fake ( )
        self . _mediator = mediator ( )
        self . _mediator . register_modules ( ** make_mediator_test_keyword_args \
            ( 'logic' 
            , self . _logic 
            , arbitrary_module_fake
            ) )
    def test_on_copy_menu_return ( self ) :
        self . _mediator . on_copy_menu_return ( )
        self . _test . assume_true ( self . _logic . _copy_menu_return )
    def test_on_creation_menu_base_created ( self ) :
        self . _mediator . on_creation_menu_base_created ( )
        self . _test . assume_true ( self . _logic . _creation_menu_base_created )
    def test_on_creation_menu_return ( self ) :
        self . _mediator . on_creation_menu_return ( )
        self . _test . assume_true ( self . _logic . _creation_menu_return )
    def test_on_edit_menu_continue ( self ) :
        self . _mediator . on_edit_menu_continue ( )
        self . _test . assume_true ( self . _logic . _edit_menu_continue )
    def test_on_edit_menu_return_to_main_menu ( self ) :
        self . _mediator . on_edit_menu_return_to_main_menu ( )
        self . _test . assume_true ( self . _logic . _edit_menu_return_to_main_menu )
    def test_on_edit_menu_save ( self ) :
        self . _mediator . on_edit_menu_save ( )
        self . _test . assume_true ( self . _logic . _edit_menu_save )
    def test_on_edit_menu_save_as ( self ) :
        self . _mediator . on_edit_menu_save_as ( )
        self . _test . assume_true ( self . _logic . _edit_menu_save_as )
    def test_on_editor_menu_button ( self ) :
        self . _mediator . on_editor_menu_button ( )
        self . _test . assume_true ( self . _logic . _editor_menu_button )
    def test_on_main_menu_copy ( self ) :
        self . _mediator . on_main_menu_copy ( )
        self . _test . assume_true ( self . _logic . _main_menu_copy )
    def test_on_main_menu_create ( self ) :
        self . _mediator . on_main_menu_create ( )
        self . _test . assume_true ( self . _logic . _main_menu_created )
    def test_on_main_menu_open ( self ) :
        self . _mediator . on_main_menu_open ( )
        self . _test . assume_true ( self . _logic . _main_menu_open )    
    def test_on_main_menu_quit ( self ) :
        self . _mediator . on_main_menu_quit ( )
        self . _test . assume_true ( self . _logic . _main_menu_quited )    
    def test_on_main_menu_rename ( self ) :
        self . _mediator . on_main_menu_rename ( )
        self . _test . assume_true ( self . _logic . _main_menu_rename )
    def test_on_open_menu_base_opened ( self ) :
        self . _mediator . on_open_menu_base_opened ( )
        self . _test . assume_true ( self . _logic . _open_menu_base_opened )
    def test_on_open_menu_return ( self ) :
        self . _mediator . on_open_menu_return ( )
        self . _test . assume_true ( self . _logic . _open_menu_return )
    def test_on_rename_menu_return ( self ) :
        self . _mediator . on_rename_menu_return ( )
        self . _test . assume_true ( self . _logic . _rename_menu_return )
    def test_on_save_as_menu_base_saved ( self ) :
        self . _mediator . on_save_as_menu_base_saved ( 'my name' )
        self . _test . assume_equal ( self . _logic . _save_as_menu_base_saved , 'my name' )
    def test_on_save_as_menu_return ( self ) :
        self . _mediator . on_save_as_menu_return ( )
        self . _test . assume_true ( self . _logic . _save_as_menu_return )
    def test_on_welcome_finished ( self ) :
        self . _mediator . on_welcome_finished ( )
        self . _test . assume_true ( self . _logic . _welcome_finished )
    def test_start_last ( self ) :
        self . _mediator . start ( )
        self . _test . assume_equal ( mediator_logic_tests . _call_history [ - 1 ] , logic_fake . start )    
